class Contract {
  num? deposit; //备用金
  num? preMoney; //定金
  String? contractNo;//合同编号
  String? startDate;
  String? endDate;
  int? bedId;
  int? intoBranchId;
  String? intoBranchName;
  String? floorNo;
  String? roomTypeName;
  String? bedNo;
  String? standardFavor;//  标准优惠
  String? specialFavor;//  特殊优惠
  List<ContractInfo>? feeRuleList;
  List<DiscountInfo>? favorList;

  Contract({
    this.feeRuleList,
    this.favorList,
    this.deposit,
    this.preMoney,
    this.contractNo,
    this.startDate,
    this.endDate,
    this.bedId,
    this.intoBranchName,
    this.floorNo,
    this.roomTypeName,
    this.bedNo,
    this.intoBranchId,
    this.standardFavor,
    this.specialFavor
  });

  factory Contract.fromJson(Map<String, dynamic> json) {
    final originList = json['feeRuleList'] as List?;
    List<ContractInfo> protocolList =
        (originList??[]).map((value) => ContractInfo.fromJson(value)).toList();
    
    final originList1 = json['favorList'] as List?;
    print('✨'*3);
    print(originList1);
    List<DiscountInfo> protocolList1 =
        (originList1??[]).map((value) => DiscountInfo.fromJson(value)).toList();

    return Contract(
        feeRuleList: protocolList,
        favorList: protocolList1,
        deposit: json['deposit'],
        preMoney: json['preMoney'],
        contractNo: json['contractNo'] ?? '',
        startDate: json['startDate'] ?? '',
        endDate: json['endDate'] ?? '',
        bedId: json['bedId'],
        intoBranchName: json['intoBranchName'],
        floorNo: json['floorNo'],
        roomTypeName: json['roomTypeName'],
        bedNo: json['bedNo'],
        intoBranchId: json['intoBranchId'],
        standardFavor: json['standardFavor'],
        specialFavor: json['specialFavor']
        );
  }
}

class ContractInfo {
  String? feeName;
  int? feeType;
  num? discount;
  num? finalMoney;
  num? money;

  ContractInfo({
    this.feeName,
    this.feeType,
    this.finalMoney,
    this.money,
    this.discount,
  });

  factory ContractInfo.fromJson(Map<String, dynamic> json) {
    return ContractInfo(
      feeName: json['feeName'],
      feeType: json['feeType'],
      finalMoney: json['finalMoney'] as double,
      money: json['money'],
      discount: json['discount'],
    );
  }
}


class DiscountInfo {
  String? schemaTypeName;
  String? actName;
  int? id;
  int? uploadVoucherFlag;
  int? schemaType;

  ///列表新增
  String? startDate;
  String? endDate;
  String? updatedDate;
  String? remark;
  int? status;
  String? statusName;
  double? onceReward1;
  double? onceReward2;
  bool? isSelected;

  ///其他收费项目
  String? name;
  String? billingModeName;
  double? monthPrice;

  DiscountInfo(
      {
        this.monthPrice,
        this.billingModeName,
        this.name,
      this.schemaTypeName,
      this.schemaType,
      this.actName,
      this.id,
      this.status,
      this.uploadVoucherFlag,
      this.startDate,
      this.endDate,
      this.updatedDate,
      this.remark,
      this.statusName,
      this.onceReward1,
      this.isSelected,
      this.onceReward2});

  DiscountInfo.fromJson(Map data) {
    schemaTypeName = data['schemaTypeName'];
    actName = data['actName'];
    id = data['id'];
    uploadVoucherFlag = data['uploadVoucherFlag'];
    startDate = data['startDate'];
    endDate = data['endDate'];
    updatedDate = data['updatedDate'];
    remark = data['remark'];
    statusName = data['statusName'];
    onceReward1 = data['onceReward1'];
    onceReward2 = data['onceReward2'];
    status = data['status'];
    isSelected = false;

    name = data['name'];
    billingModeName = data['billingModeName'];
    monthPrice = data['monthPrice'];
    schemaType = data['schemaType'];
  }
}
